package task

import event.SellChangedEvent
import ext.log
import manager.AsyncTask
import manager.NetworkManager
import org.greenrobot.eventbus.EventBus

class RefreshSellTask : Runnable {
    companion object {
        var SellStatus = SellChangedEvent.START
    }

    override fun run() {
        try {
            val ret = NetworkManager.refreshSellWithServer()
            log("--$ret", "销售状态")
            SellStatus = ret.toInt()
            EventBus.getDefault().post(SellChangedEvent(SellStatus))
        } catch (e: Exception) {
            e.printStackTrace()
            AsyncTask.postDelayed(this, 60 * 1000)
        }
    }
}